/*
 * ClientLocaliView.java
 */
package clientlocali;

import java.awt.Image;
import java.awt.Toolkit;

import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.swing.Timer;
import javax.swing.Icon;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;
import net.java.dev.jaxb.array.StringArray;

/**
 * The application's main frame.
 */
public class ClientLocaliView extends FrameView {
    
    public ClientLocaliView(SingleFrameApplication app) {
        super(app);
        this.getFrame().setResizable(false);
        initComponents();
        Image img = Toolkit.getDefaultToolkit().getImage("drink4.gif");
        //setto l'icona del frame
        this.getFrame().setIconImage(img);
        loginPanel.setVisible(true);
        mainPanel.setVisible(true);
        listPanel.setVisible(false);
        accedi.addActionListener(new AllButtonListener());
        aggiorna.addActionListener(new AllButtonListener());


        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            
            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String) (evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer) (evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
    }
    
    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = ClientLocaliApp.getApplication().getMainFrame();
            aboutBox = new ClientLocaliAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        ClientLocaliApp.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        listPanel = new javax.swing.JPanel();
        aggiorna = new javax.swing.JButton();
        scrollTable = new javax.swing.JScrollPane();
        prenotazioniTabella = new javax.swing.JTable();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        loginPanel = new javax.swing.JPanel();
        titolo = new javax.swing.JLabel();
        nome = new javax.swing.JLabel();
        pass = new javax.swing.JLabel();
        username = new javax.swing.JTextField();
        password = new javax.swing.JPasswordField();
        accedi = new javax.swing.JButton();
        jToggleButton1 = new javax.swing.JToggleButton();

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(clientlocali.ClientLocaliApp.class).getContext().getResourceMap(ClientLocaliView.class);
        mainPanel.setBackground(resourceMap.getColor("mainPanel.background")); // NOI18N
        mainPanel.setName("mainPanel"); // NOI18N

        listPanel.setBackground(resourceMap.getColor("listPanel.background")); // NOI18N
        listPanel.setName("listPanel"); // NOI18N
        listPanel.setPreferredSize(new java.awt.Dimension(640, 640));

        aggiorna.setText(resourceMap.getString("aggiorna.text")); // NOI18N
        aggiorna.setName("aggiorna"); // NOI18N

        scrollTable.setName("scrollTable"); // NOI18N

        prenotazioniTabella.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Data Prenotazione", "Numero Posti", "Nome", "Cognome", "Evento", "Arrivato"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Boolean.class, java.lang.Boolean.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, true
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        prenotazioniTabella.setColumnSelectionAllowed(true);
        prenotazioniTabella.setName("prenotazioniTabella"); // NOI18N
        prenotazioniTabella.setRowHeight(26);
        prenotazioniTabella.setSurrendersFocusOnKeystroke(true);
        scrollTable.setViewportView(prenotazioniTabella);
        prenotazioniTabella.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        prenotazioniTabella.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("prenotazioniTabella.columnModel.title0")); // NOI18N
        prenotazioniTabella.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("prenotazioniTabella.columnModel.title1")); // NOI18N
        prenotazioniTabella.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("prenotazioniTabella.columnModel.title2")); // NOI18N
        prenotazioniTabella.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("prenotazioniTabella.columnModel.title3")); // NOI18N
        prenotazioniTabella.getColumnModel().getColumn(4).setHeaderValue(resourceMap.getString("prenotazioniTabella.columnModel.title4")); // NOI18N
        prenotazioniTabella.getColumnModel().getColumn(5).setHeaderValue(resourceMap.getString("prenotazioniTabella.columnModel.title5")); // NOI18N

        statusPanel.setName("statusPanel"); // NOI18N
        statusPanel.setPreferredSize(new java.awt.Dimension(25, 25));

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 316, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 296, Short.MAX_VALUE)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, statusPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(160, 160, 160))
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusMessageLabel)
                    .addComponent(statusAnimationLabel)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(3, 3, 3))
        );

        javax.swing.GroupLayout listPanelLayout = new javax.swing.GroupLayout(listPanel);
        listPanel.setLayout(listPanelLayout);
        listPanelLayout.setHorizontalGroup(
            listPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(scrollTable, javax.swing.GroupLayout.DEFAULT_SIZE, 746, Short.MAX_VALUE)
            .addGroup(listPanelLayout.createSequentialGroup()
                .addGap(80, 80, 80)
                .addComponent(aggiorna, javax.swing.GroupLayout.PREFERRED_SIZE, 587, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(listPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(listPanelLayout.createSequentialGroup()
                    .addGap(0, 215, Short.MAX_VALUE)
                    .addComponent(statusPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 316, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 215, Short.MAX_VALUE)))
        );
        listPanelLayout.setVerticalGroup(
            listPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, listPanelLayout.createSequentialGroup()
                .addComponent(scrollTable, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE)
                .addGap(11, 11, 11)
                .addComponent(aggiorna, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(listPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(listPanelLayout.createSequentialGroup()
                    .addGap(0, 219, Short.MAX_VALUE)
                    .addComponent(statusPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 219, Short.MAX_VALUE)))
        );

        loginPanel.setBackground(resourceMap.getColor("loginPanel.background")); // NOI18N
        loginPanel.setName("loginPanel"); // NOI18N
        loginPanel.setPreferredSize(new java.awt.Dimension(640, 640));

        titolo.setBackground(resourceMap.getColor("titolo.background")); // NOI18N
        titolo.setFont(resourceMap.getFont("titolo.font")); // NOI18N
        titolo.setForeground(resourceMap.getColor("titolo.foreground")); // NOI18N
        titolo.setIcon(resourceMap.getIcon("titolo.icon")); // NOI18N
        titolo.setText(resourceMap.getString("titolo.text")); // NOI18N
        titolo.setName("titolo"); // NOI18N

        nome.setFont(resourceMap.getFont("nome.font")); // NOI18N
        nome.setForeground(resourceMap.getColor("nome.foreground")); // NOI18N
        nome.setText(resourceMap.getString("nome.text")); // NOI18N
        nome.setName("nome"); // NOI18N

        pass.setFont(resourceMap.getFont("pass.font")); // NOI18N
        pass.setForeground(resourceMap.getColor("pass.foreground")); // NOI18N
        pass.setText(resourceMap.getString("pass.text")); // NOI18N
        pass.setName("pass"); // NOI18N

        username.setFont(resourceMap.getFont("username.font")); // NOI18N
        username.setText(resourceMap.getString("username.text")); // NOI18N
        username.setName("username"); // NOI18N

        password.setFont(resourceMap.getFont("password.font")); // NOI18N
        password.setText(resourceMap.getString("password.text")); // NOI18N
        password.setName("password"); // NOI18N

        accedi.setText(resourceMap.getString("accedi.text")); // NOI18N
        accedi.setName("accedi"); // NOI18N

        javax.swing.GroupLayout loginPanelLayout = new javax.swing.GroupLayout(loginPanel);
        loginPanel.setLayout(loginPanelLayout);
        loginPanelLayout.setHorizontalGroup(
            loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, loginPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(nome)
                    .addComponent(pass))
                .addGap(61, 61, 61)
                .addGroup(loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(password)
                    .addComponent(username, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE))
                .addGap(208, 208, 208))
            .addGroup(loginPanelLayout.createSequentialGroup()
                .addComponent(titolo)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(loginPanelLayout.createSequentialGroup()
                .addGap(322, 322, 322)
                .addComponent(accedi)
                .addContainerGap(359, Short.MAX_VALUE))
        );
        loginPanelLayout.setVerticalGroup(
            loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, loginPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(titolo, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
                .addGroup(loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(nome))
                .addGap(37, 37, 37)
                .addGroup(loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pass)
                    .addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(46, 46, 46)
                .addComponent(accedi)
                .addGap(35, 35, 35))
        );

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(listPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 746, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(loginPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 736, Short.MAX_VALUE))
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                .addComponent(loginPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 458, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(listPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 463, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jToggleButton1.setText(resourceMap.getString("jToggleButton1.text")); // NOI18N
        jToggleButton1.setName("jToggleButton1"); // NOI18N

        setComponent(mainPanel);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JButton accedi;
    public javax.swing.JButton aggiorna;
    private javax.swing.JToggleButton jToggleButton1;
    public javax.swing.JPanel listPanel;
    public javax.swing.JPanel loginPanel;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JLabel nome;
    private javax.swing.JLabel pass;
    public javax.swing.JPasswordField password;
    public javax.swing.JTable prenotazioniTabella;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JScrollPane scrollTable;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JLabel titolo;
    public javax.swing.JTextField username;
    // End of variables declaration//GEN-END:variables
    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private JDialog aboutBox;
    public List<String[]> prenotazioni = new ArrayList<String[]>();
    
    public class CambiaStato implements TableModelListener {
        
        public void tableChanged(TableModelEvent evt) {
            if (evt.getType() == TableModelEvent.UPDATE) {
                int column = evt.getColumn();
                int row = evt.getFirstRow();
                String[] tmp = prenotazioni.get(row);
                
                
                try {
                    prj.ByNightWS_Service service2 = new prj.ByNightWS_Service();
                    prj.ByNightWS port2 = service2.getByNightWSPort();
                    // TODO process result here
                    boolean result = port2.cambiaStatoPrenotazione(tmp[column]);
                    if (result) {
                        /* JOptionPane.showMessageDialog(mainPanel,
                        "Stato della prenotazione aggiornato.",
                        "Prenotazione Ok",
                        JOptionPane.PLAIN_MESSAGE);*/
                         JOptionPane.showMessageDialog(mainPanel,
                                "Stato della prenotazione aggiornato",
                                "Prenotazione Ok",
                                JOptionPane.INFORMATION_MESSAGE);
                    } else {
                        JOptionPane.showMessageDialog(mainPanel,
                                "Stato della prenotazione non aggiornato.",
                                "Prenotazione Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                    
                } catch (Exception ex) {
                }
            }
        }
    }
    
    class AllButtonListener implements ActionListener {
        
        public void actionPerformed(ActionEvent e) {
            String user = username.getText();
            String pass = password.getText();
            String locale = "locale";
            JButton s = (JButton) e.getSource();
            if (s == accedi) {
                loginLocale(user, pass, locale);
            } else if (s == aggiorna) {
                tablePrenotazioni(user);
                
            }
        }
        
        private void tablePrenotazioni(String user) {
            prenotazioniTabella.setModel(new javax.swing.table.DefaultTableModel(
                    new Object[][]{},
                    new String[]{
                        "Data Prenotazione", "Numero Posti", "Nome", "Cognome", "Evento", "Arrivato"
                    }) {

                Class[] types = new Class[]{
                    java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Boolean.class, java.lang.Boolean.class
                };
                boolean[] canEdit = new boolean[]{
                    false, false, false, false, false, true
                };
                
                public Class getColumnClass(int columnIndex) {
                    return types[columnIndex];
                }
                
                public boolean isCellEditable(int rowIndex, int columnIndex) {
                    return canEdit[columnIndex];
                }
            });
            prenotazioniTabella.setColumnSelectionAllowed(true);
            prenotazioniTabella.setName("prenotazioniTabella"); // NOI18N
            prenotazioniTabella.setRowHeight(26);
            prenotazioniTabella.setSurrendersFocusOnKeystroke(true);
            scrollTable.setViewportView(prenotazioniTabella);
            prenotazioniTabella.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
            prenotazioniTabella.getColumnModel().getColumn(0).setHeaderValue(getResourceMap().getString("prenotazioniTabella.columnModel.title0")); // NOI18N
            prenotazioniTabella.getColumnModel().getColumn(1).setHeaderValue(getResourceMap().getString("prenotazioniTabella.columnModel.title1")); // NOI18N
            prenotazioniTabella.getColumnModel().getColumn(2).setHeaderValue(getResourceMap().getString("prenotazioniTabella.columnModel.title2")); // NOI18N
            prenotazioniTabella.getColumnModel().getColumn(3).setHeaderValue(getResourceMap().getString("prenotazioniTabella.columnModel.title3")); // NOI18N
            prenotazioniTabella.getColumnModel().getColumn(4).setHeaderValue(getResourceMap().getString("prenotazioniTabella.columnModel.title4")); // NOI18N
            prenotazioniTabella.getColumnModel().getColumn(5).setHeaderValue(getResourceMap().getString("prenotazioniTabella.columnModel.title5")); // NOI18N

            try {
                prj.ByNightWS_Service service1 = new prj.ByNightWS_Service();
                prj.ByNightWS port1 = service1.getByNightWSPort();
                // TODO process result here

                java.util.List<net.java.dev.jaxb.array.StringArray> result = port1.visualizzaPrenotazioni(user);
                for (int i = 0; i < result.size(); i++) {
                    List<String> p = result.get(i).getItem();
                    DefaultTableModel model = (DefaultTableModel) prenotazioniTabella.getModel();
                    model.addRow(new Object[1]);
                    prenotazioniTabella.setModel(model);
                    //prenotazioniTabella.repaint();

                    String[] newElement = new String[6];
                    for (int j = 0; j < 5; j++) {
                        newElement[j] = p.get(j);
                        if (j == 4 && p.get(j) != null) {
                            prenotazioniTabella.setValueAt(true, i, j);
                            
                        } else {
                            prenotazioniTabella.setValueAt(p.get(j), i, j);
                        }
                        
                    }
                    newElement[5] = p.get(5);
                    prenotazioni.add(newElement);
                    
                    
                }
                prenotazioniTabella.getModel().addTableModelListener(new CambiaStato());
                
                prenotazioniTabella.updateUI();
                
                
            } catch (Exception ex) {
            }
            
            
        }
        
        private void loginLocale(String user, String pass, String locale) {
            try {
                
                prj.ByNightWS_Service service = new prj.ByNightWS_Service();
                prj.ByNightWS port = service.getByNightWSPort();
                // TODO process result here
                java.lang.String result = port.login(user, pass, locale);
                if (result != null) {
                    loginPanel.setVisible(false);
                    listPanel.setVisible(true);
                    tablePrenotazioni(user);
                    
                } else {
                    JOptionPane.showMessageDialog(mainPanel,
                            "Autenticazione Fallita. Nome Locale o Password errate.",
                            "Login Error",
                            JOptionPane.ERROR_MESSAGE);
                }
            } catch (Exception ex) {
            }
            
            
        }
    }
}
